<extend name="Public/base" />
<block name="body">
	<div class="row">
		<div class="col-md-12">
			<!-- BEGIN EXAMPLE TABLE PORTLET-->
			<div class="portlet-body" id="cont">
				<div class="table-toolbar">
					<div class="btn-group" style="float:left">
						<a href="{:U('addRules')}" class="btn green">
							新 增 
						</a>
					</div>
				</div>

				<div class="clearfix"></div>

				<table class="table table-striped table-bordered table-hover dataTable" id="checkboxtable">
					<thead>
						<tr pid="0">
							<th width="5%">ID</th>
							<th>分类名称</th>
							<th>描述</th>
							<th>操作</th>
						</tr>
					</thead>

					<tbody>
						<if condition="$rules">
							<volist name="rules" id="vo">
								<tr class="odd gradeX" id='{$vo.id}' pid="{$vo.pid}">
									<td>{$vo.id}</td>
									<td>
										<?php $get_child = get_category_children($rules,$vo['id']); ?>
										<if condition="$vo['pid'] NEQ 0">
											{:str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',$vo['level'])}∟
												<span class="row-details row-details-open"></span>&nbsp;
												{$vo.title}（{$vo.name}）&nbsp;&nbsp;<a href="{:U('addRules',array('pid'=>$vo['id']))}"><i class="glyphicon glyphicon-plus"></i></a>
										<else/>
										    <span class="row-details row-details-open"></span>&nbsp;{$vo.title}（{$vo.name}）&nbsp;&nbsp;<a href="{:U('addRules',array('pid'=>$vo['id']))}"><i class="glyphicon glyphicon-plus"></i></a>
										</if>
									</td>
									<td>{$vo.condition}</td>
									<td>
										<span class="">
											<a href="{:U('editRules',array('id'=>$vo['id']))}">编辑</a>
										</span>&nbsp;&nbsp;
										<span class="">
											<a href="{:U('delRules',array('id'=>$vo['id']))}" class="ajax-get">删除</a>
										</span>
									</td>
								</tr>
							</volist>
							<else/>
							<tr><td colspan="11" align="center">没有找到相关数据！</td></tr>
						</if>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</block>
<block name="script">
	<script type="text/javascript">
	$(function() {
		//$( 'tr[pid!=0]' ).hide();

		$( '.row-details-open' ).toggle( function () {
			var index = $( this ).parents('tr').attr('id');
			$( this ).removeClass( 'row-details-open' );
			$( this ).addClass( 'row-details-close' );
			$( 'tr[pid='+ index +']' ).hide();
			
		}, function () {
			var index = $( this ).parents('tr').attr('id');
			$( this ).removeClass( 'row-details-close' );
			$( this ).addClass( 'row-details-open' );
			$( 'tr[pid='+ index +']' ).show();
		} );
	});
	</script>
</block>	